const multer = require('multer');
const path = require('path');
const storage = multer.diskStorage({
  destination: (req, file, cb) => {
    cb(null, 'static/images');
  },
  filename: (req, file, cb) => {
    let extname = path.extname(file.originalname);
    let randomnum = Math.ceil(Math.random() * 10);
    let filename = file.fieldname + '-' + randomnum + Date.now() + extname;
    cb(null, filename);
  },
});
const upload = multer({ storage });
module.exports = upload;
